<?php

session_start();

$article =  $_REQUEST['article'];

$dir = dirname($article);
$file = basename($article);

chdir($_SERVER['DOCUMENT_ROOT'] . "/" . $dir);


if (! is_dir("archive")) mkdir("archive");

$timestamp = $_SESSION["username"] . "_" . date('Y_m_d_H_i_s');

copy ($file,"archive/{$file}.{$timestamp}");
rename("{$file}.edit",$file);
unset($_SESSION["edit_on"]);
echo "archive/{$file}.{$timestamp}";
?>